export default {
  setHomeNewGame(state, data) { 
       // H5游戏数据
        state.Home.h5Game = data.one
        // 新游速递数据
        state.Home.newGame = data.one
        state.Home.hotDown = data.one
        state.Home.choicest = data.one
  },


  // 首页 -> 游戏资讯赋值
  setHomeGameNews(state, data) {
    data.newsList.forEach((v, i) => {
      if (i === 0) {
        v.activate = true
      } else {
        v.activate = false
      }
    })
    data.newsGift.forEach((v, i) => {
      if (i === 0) {
        v.activate = true
      } else {
        v.activate = false
      }
    })
 
    console.log('游戏资讯赋值')
    console.log(JSON.stringify(data))
    
    state.Home.gameNews = data
  },
  
  // 首页 -> 轮播图赋值
  setHomeBanner(state, data) {
    state.Home.banner = data
  },
  // 首页 -> 精彩活动赋值
  setHomeActivity(state, data) {
    state.Home.activity = data
  },
  // 游戏页面  -> 游戏列表
  setGameList(state, data) {
    state.GameList = data
  },
  // 榜单页面  -> 榜单数据
  setListData(state, data) {
    // 避免数据重复添加
    if (state.listPage !== data.page) {
      data.forEach((v, i) => {
        if (i < 10) {
          if (state.listPage === 0) {
            i === 0 ? v.activate = true : v.activate = false
          } else {
            v.activate = false
          }
          state.ListData.new.push(v)
        }
        if (i > 9 && i < 20) {
          if (state.listPage === 0) {
            i === 10 ? v.activate = true : v.activate = false
          } else {
            v.activate = false
          }
          state.ListData.hot.push(v)
        }
        if (i > 19) {
          if (state.listPage === 0) {
            i === 20 ? v.activate = true : v.activate = false
          } else {
            v.activate = false
          }
          state.ListData.h5.push(v)
        }
      })
    }
    // 记录当前分页值
    state.listPage = data.page
  },
  // 游戏详情页面
  setGameDetails(state, data) {
    data.sidebarGame.language = '简体中文',
    data.sidebarGame.version = '1.0.2',
    data.sidebarGame.update = '2017-08-09',
    data.sidebarGame.cp = '米玩游戏'
    data.sidebarGame.qrCode = 'http://fanyi.baidu.com/static/translation/img/footer/wechat_76663d3.jpg'
    if (data.gameId % 2) {
      data.sidebarGame.system = '安卓6.0以上、iOS7.0以上'
    } else {
      data.sidebarGame.download_number = false
    }
    state.GameDetails = data
  },
  // 游戏详情页面 -> 底部相似游戏
  setBottomGame(state, data) {
    state.bottomGame = data
  },
  // 礼包页面 -> 游戏礼包
  setGiftGame(state, data) {
    state.GiftGame = data
  },
  // 礼包详情页 -> 游戏礼包详情
  setGiftDetails(state, data) {
    state.GiftDetails = data
  },
  // 鼠标进入
  mouseHover(state, option) {
    // state.Home.gameNews[option.name].map(v => v.activate = false)
    // state.Home.gameNews[option.name][option.index].activate = true
  }
}